package com.c.ctgproject.adapter.guang

import android.content.Context
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import com.c.ctgproject.R
import com.c.ctgproject.base.BaseEmptyRecyclerViewAdapterV2
import com.c.ctgproject.entity.guang.MaterialOutCheckDetailEntity
import com.c.ctgproject.utils.handlerNull
import com.c.ctgproject.utils.noDataHandler

class OutDetailForCheckAdapter(private val context: Context, private val mList: List<MaterialOutCheckDetailEntity.DataBean.OutItemsBean>) : BaseEmptyRecyclerViewAdapterV2(context, mList) {

    override fun createViewHolder(parent: ViewGroup): RecyclerView.ViewHolder {
        val view = LayoutInflater.from(context).inflate(R.layout.item_battery_out_detail_for_check_list, parent, false)
        return MyViewHolder(view)
    }

    override fun handlerData(holder: RecyclerView.ViewHolder, position: Int) {
        if (holder is MyViewHolder) {
            val data = mList[position]
            holder.name.text = data.materialName.noDataHandler()
            holder.count.text = data.count.noDataHandler()
            holder.unit.text = data.unit.handlerNull()
            holder.materialCodeTV.text = data.materialCode.noDataHandler()
            holder.mLine.visibility = if (position == mList.size - 1) View.GONE else View.VISIBLE
        }
    }

    inner class MyViewHolder(view: View) : RecyclerView.ViewHolder(view) {
        val materialCodeTV: TextView = view.findViewById(R.id.materialCodeTV)
        val name: TextView = view.findViewById(R.id.name)
        val count: TextView = view.findViewById(R.id.count)
        val unit: TextView = view.findViewById(R.id.unit)
        val mLine: View = view.findViewById(R.id.mLine)


    }
}